<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8">
  <title>登录 - 墨语智学</title>
  <script src="https://cdn.tailwindcss.com"></script>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@500;700&family=ZCOOL+XiaoWei&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <style>
    body {
      min-height: 100vh;
      background-color: #F5F7FF;
      background-image: 
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" opacity="0.05"><path d="M10,10 Q50,50 90,10 T170,50 T250,10" stroke="%232962FF" fill="none" stroke-width="2"/><path d="M300,100 Q350,50 400,100 T500,50 T600,100" stroke="%239C27B0" fill="none" stroke-width="2"/><path d="M100,200 Q150,150 200,200 T300,150 T400,200" stroke="%232962FF" fill="none" stroke-width="2"/></svg>'),
        radial-gradient(circle at 10% 10%, rgba(41, 98, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 90% 90%, rgba(156, 39, 176, 0.05) 0%, transparent 50%);
      font-family: 'Noto Sans SC', sans-serif;
      position: relative;
      overflow-x: hidden;
    }
    body::before {
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" opacity="0.03"><path d="M800,50 Q850,100 900,50" stroke="%232962FF" fill="none" stroke-width="3"/><path d="M700,150 Q750,200 800,150" stroke="%239C27B0" fill="none" stroke-width="3"/></svg>');
      background-repeat: no-repeat;
      background-position: 80% 30%;
      pointer-events: none;
      z-index: -1;
    }
    .login-container {
      box-shadow: 0 10px 25px -5px rgba(41, 98, 255, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
      transition: all 0.3s ease;
      border: 1px solid rgba(41, 98, 255, 0.1);
      background-color: rgba(255, 255, 255, 0.95);
      backdrop-filter: blur(10px);
    }
    .logo-text {
      font-family: 'ZCOOL XiaoWei', serif;
      font-size: 2.5rem;
      font-weight: bold;
      background: linear-gradient(90deg, #2962FF, #9C27B0);
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      letter-spacing: 1px;
      position: relative;
      display: inline-block;
      cursor: pointer;
    }
    .logo-text::after {
      content: '';
      position: absolute;
      left: 0;
      bottom: -5px;
      width: 100%;
      height: 3px;
      background: linear-gradient(90deg, #2962FF, #9C27B0);
      border-radius: 3px;
      transform: scaleX(0);
      transition: transform 0.3s ease;
    }
    .logo-text:hover::after {
      transform: scaleX(1);
    }
    .alert {
      opacity: 0;
      transform: translateY(-10px);
      transition: all 0.3s ease;
    }
    .alert.show {
      opacity: 1;
      transform: translateY(0);
    }
    .input-field {
      transition: all 0.3s ease;
      border: 1px solid #E5E7EB;
    }
    .input-field:focus {
      box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.2);
      border-color: #2962FF;
    }
    .tab-button {
      transition: all 0.3s ease;
      position: relative;
    }
    .tab-button.active {
      color: #2962FF;
      font-weight: 600;
    }
    .tab-button.active::after {
      content: '';
      position: absolute;
      bottom: -2px;
      left: 0;
      width: 100%;
      height: 3px;
      background: linear-gradient(90deg, #2962FF, #9C27B0);
      border-radius: 3px;
    }
    .social-btn {
      transition: all 0.3s ease;
      transform: scale(1);
    }
    .social-btn:hover {
      transform: scale(1.1);
    }
    .btn-primary {
      background: linear-gradient(90deg, #2962FF, #9C27B0);
      color: white;
      transition: all 0.3s ease;
      box-shadow: 0 4px 6px -1px rgba(41, 98, 255, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }
    .btn-primary:hover {
      opacity: 0.9;
      transform: translateY(-1px);
      box-shadow: 0 10px 15px -3px rgba(41, 98, 255, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    }
    .btn-primary:focus {
      outline: none;
      box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.3);
    }
    .toggle-password {
      transition: all 0.2s ease;
    }
    .toggle-password:hover {
      color: #2962FF;
    }
    .logo-icon {
      width: 64px;
      height: 64px;
      background: linear-gradient(135deg, #2962FF, #9C27B0);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 6px rgba(41, 98, 255, 0.2);
      margin-bottom: 12px;
      cursor: pointer;
    }
    .logo-icon i {
      color: white;
      font-size: 28px;
    }
    .ink-effect {
      position: absolute;
      width: 300px;
      height: 300px;
      background: radial-gradient(circle, rgba(41,98,255,0.1) 0%, rgba(255,255,255,0) 70%);
      border-radius: 50%;
      z-index: -1;
      opacity: 0.5;
    }
    .ink-effect:nth-child(1) {
      top: -100px;
      right: -100px;
      background: radial-gradient(circle, rgba(156,39,176,0.1) 0%, rgba(255,255,255,0) 70%);
    }
    .ink-effect:nth-child(2) {
      bottom: -50px;
      left: -50px;
    }
    .home-btn {
      transition: all 0.3s ease;
    }
    .home-btn:hover {
      transform: scale(1.1);
      color: #2962FF;
    }
  </style>
</head>
<body>
<!-- 水墨效果背景元素 -->
<div class="ink-effect"></div>
<div class="ink-effect"></div>

<div class="min-h-screen flex flex-col items-center justify-center px-4 py-8">
  <div class="w-full max-w-md mx-auto">
    <!-- 顶部logo区域 -->
    <div class="text-center mb-8">
      <div class="flex flex-col items-center justify-center gap-2">
        <div class="logo-icon" onclick="window.location.href='墨语智学首页.html'">
          <i class="fas fa-graduation-cap"></i>
        </div>
        <h1 class="logo-text text-3xl" onclick="window.location.href='墨语智学首页.html'">墨语智学</h1>
        <p class="text-gray-500 mt-1 text-sm">大学生智能学习平台</p>
      </div>
    </div>
    
    <!-- 登录卡片 -->
    <div class="login-container rounded-xl p-8 relative overflow-hidden">
      <!-- 添加返回首页按钮 -->
      <a href="墨语智学首页.html" class="absolute left-6 top-6 text-gray-500 home-btn">
        <i class="fas fa-home text-lg"></i>
      </a>
      
      <!-- 登录状态提示 -->
      <div id="alert" class="alert absolute top-0 left-0 right-0 p-4 rounded-t-xl"></div>
      
      <!-- 登录方式切换 -->
      <div class="flex border-b mb-8">
        <button id="tab-password" class="tab-button flex-1 py-3 font-medium text-primary active">
          密码登录
        </button>
        <button id="tab-code" class="tab-button flex-1 py-3 font-medium text-gray-500">
          验证码登录
        </button>
      </div>
      
      <!-- 密码登录表单 -->
      <form id="password-form" class="space-y-6">
        <div class="space-y-1">
          <label for="username" class="block text-sm font-medium text-gray-700">账号</label>
          <div class="relative">
            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
              <i class="fas fa-user text-gray-400"></i>
            </div>
            <input type="text" id="username" name="username" 
                   class="w-full pl-10 pr-4 py-3 border rounded-lg input-field focus:outline-none"
                   placeholder="请输入账号" value="student2025">
          </div>
        </div>
        
        <div class="space-y-1">
          <label for="password" class="block text-sm font-medium text-gray-700">密码</label>
          <div class="relative">
            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
              <i class="fas fa-lock text-gray-400"></i>
            </div>
            <input type="password" id="password" name="password" 
                   class="w-full pl-10 pr-10 py-3 border rounded-lg input-field focus:outline-none"
                   placeholder="请输入密码" value="moyu123">
            <div class="absolute inset-y-0 right-0 pr-3 flex items-center">
              <i class="fas fa-eye-slash text-gray-400 cursor-pointer toggle-password"></i>
            </div>
          </div>
        </div>
        
        <div class="flex items-center justify-between">
          <div class="flex items-center">
            <input type="checkbox" id="remember" name="remember" class="h-4 w-4 text-primary rounded focus:ring-primary">
            <label for="remember" class="ml-2 text-sm text-gray-600">记住我</label>
          </div>
          <a href="#" class="text-sm text-primary hover:underline">忘记密码?</a>
        </div>
        
        <button type="submit" class="w-full btn-primary py-3 rounded-lg font-medium">
          登录
        </button>
      </form>
      
      <!-- 验证码登录表单 (默认隐藏) -->
      <form id="code-form" class="space-y-6 hidden">
        <div class="space-y-1">
          <label class="block text-sm font-medium text-gray-700">手机号</label>
          <div class="flex gap-2">
            <select class="w-24 px-3 py-3 border rounded-lg focus:outline-none focus:border-primary bg-white">
              <option>+86</option>
              <option>+1</option>
              <option>+81</option>
            </select>
            <input type="tel" class="flex-1 px-4 py-3 border rounded-lg input-field focus:outline-none"
                   placeholder="请输入手机号">
          </div>
        </div>
        
        <div class="space-y-1">
          <label class="block text-sm font-medium text-gray-700">验证码</label>
          <div class="flex gap-2">
            <input type="text" class="flex-1 px-4 py-3 border rounded-lg input-field focus:outline-none"
                   placeholder="请输入验证码">
            <button type="button" class="w-32 bg-gray-100 text-gray-700 py-3 rounded-lg font-medium hover:bg-gray-200 transition">
              获取验证码
            </button>
          </div>
        </div>
        
        <button type="submit" class="w-full btn-primary py-3 rounded-lg font-medium">
          登录
        </button>
      </form>
      
      <!-- 注册链接 -->
      <div class="mt-6 text-center text-sm text-gray-500">
        还没有账号? <a href="#" class="text-primary font-medium hover:underline hover:text-secondary">立即注册</a>
      </div>
      
      <!-- 分割线 -->
      <div class="mt-6 relative">
        <div class="absolute inset-0 flex items-center">
          <div class="w-full border-t border-gray-200"></div>
        </div>
        <div class="relative flex justify-center">
          <span class="px-2 bg-white text-gray-500 text-sm">其他登录方式</span>
        </div>
      </div>
      
      <!-- 社交登录 -->
      <div class="mt-6 flex justify-center gap-4">
        <button class="social-btn w-12 h-12 rounded-full bg-blue-50 text-blue-600 flex items-center justify-center hover:bg-blue-100 shadow-sm">
          <i class="fab fa-weixin text-xl"></i>
        </button>
        <button class="social-btn w-12 h-12 rounded-full bg-red-50 text-red-600 flex items-center justify-center hover:bg-red-100 shadow-sm">
          <i class="fab fa-qq text-xl"></i>
        </button>
        <button class="social-btn w-12 h-12 rounded-full bg-gray-50 text-gray-600 flex items-center justify-center hover:bg-gray-100 shadow-sm">
          <i class="fas fa-envelope text-xl"></i>
        </button>
      </div>
    </div>
    
    <!-- 页脚 -->
    <div class="mt-8 text-center text-xs text-gray-400">
      <p>© 2025 墨语智学 版权所有</p>
      <p class="mt-1">蜀ICP备202502584号 · <a href="#" class="hover:text-gray-600">隐私政策</a> · <a href="#" class="hover:text-gray-600">服务条款</a></p>
    </div>
  </div>
</div>

<script>
  // 内嵌的auth模块
  const authModule = (function() {
    // 用户数据存储键名
    const USER_STORAGE_KEY = 'moyu_user';
    
    // 当前用户数据
    let currentUser = null;
    
    // 初始化函数 - 在所有页面加载时调用
    function initialize() {
      // 从本地存储加载用户数据
      loadUserData();
    }
    
    // 加载用户数据
    function loadUserData() {
      const userData = localStorage.getItem(USER_STORAGE_KEY);
      if (userData) {
        currentUser = JSON.parse(userData);
      }
    }
    
    // 保存用户数据
    function saveUserData(user) {
      localStorage.setItem(USER_STORAGE_KEY, JSON.stringify(user));
      currentUser = user;
    }
    
    // 清除用户数据
    function clearUserData() {
      localStorage.removeItem(USER_STORAGE_KEY);
      currentUser = null;
    }
    
    // 处理登录
    function handleLogin(userData) {
      saveUserData(userData);
    }
    
    // 处理登出
    function handleLogout() {
      clearUserData();
    }
    
    // 检查登录状态
    function isLoggedIn() {
      return currentUser !== null;
    }
    
    // 获取当前用户
    function getCurrentUser() {
      return currentUser;
    }
    
    // 公共API
    return {
      initialize,
      handleLogin,
      handleLogout,
      isLoggedIn,
      getCurrentUser
    };
  })();

  // 页面加载完成后初始化
  document.addEventListener('DOMContentLoaded', function() {
    // 检查是否已登录
    if (authModule.isLoggedIn()) {
      // 如果已登录，直接跳转到测试页面
      window.location.href = '墨语智学测试.html';
      return;
    }
    
    // 切换登录方式
    document.getElementById('tab-password').addEventListener('click', function() {
      this.classList.add('text-primary', 'active');
      document.getElementById('tab-code').classList.remove('text-primary', 'active');
      document.getElementById('password-form').classList.remove('hidden');
      document.getElementById('code-form').classList.add('hidden');
    });
    
    document.getElementById('tab-code').addEventListener('click', function() {
      this.classList.add('text-primary', 'active');
      document.getElementById('tab-password').classList.remove('text-primary', 'active');
      document.getElementById('code-form').classList.remove('hidden');
      document.getElementById('password-form').classList.add('hidden');
    });
    
    // 显示/隐藏密码
    document.querySelector('.toggle-password').addEventListener('click', function() {
      const passwordInput = document.getElementById('password');
      if (passwordInput.type === 'password') {
        passwordInput.type = 'text';
        this.classList.replace('fa-eye-slash', 'fa-eye');
      } else {
        passwordInput.type = 'password';
        this.classList.replace('fa-eye', 'fa-eye-slash');
      }
    });
    
    // 登录表单提交
    document.getElementById('password-form').addEventListener('submit', function(e) {
      e.preventDefault();
      
      const username = document.getElementById('username').value;
      const password = document.getElementById('password').value;
      const rememberMe = document.getElementById('remember').checked;
      const alertBox = document.getElementById('alert');
      
      // 清除之前的提示
      alertBox.classList.remove('show', 'bg-success/10', 'text-success', 'bg-error/10', 'text-error');
      alertBox.innerHTML = '';
      
      // 模拟网络请求延迟
      setTimeout(() => {
        if (username === 'student2025' && password === 'moyu123') {
          // 登录成功
          alertBox.classList.add('show', 'bg-success/10', 'text-success');
          alertBox.innerHTML = '<i class="fas fa-check-circle mr-2"></i> 登录成功，正在跳转...';
          
          // 模拟用户数据
          const userData = {
            id: 1,
            username: 'student2025',
            name: '王梦琪',
            avatar: 'https://imgur.la/images/2025/06/07/94B2FFC12D41C799B69B2668BBA16BE7.jpg'
          };
          
          // 使用auth.js中的handleLogin函数
          authModule.handleLogin(userData);
          // 登录成功后跳转到测试页面
          setTimeout(() => {
            window.location.href = '墨语智学测试.html';
          }, 1500);
        } else {
          // 登录失败
          alertBox.classList.add('show', 'bg-error/10', 'text-error');
          
          if (!username || !password) {
            alertBox.innerHTML = '<i class="fas fa-exclamation-circle mr-2"></i> 请输入账号和密码';
          } else if (username !== 'student2025') {
            alertBox.innerHTML = '<i class="fas fa-exclamation-circle mr-2"></i> 账号不存在';
          } else {
            alertBox.innerHTML = '<i class="fas fa-exclamation-circle mr-2"></i> 密码错误，请重试';
          }
          
          // 3秒后自动隐藏
          setTimeout(() => {
            alertBox.classList.remove('show');
          }, 3000);
        }
      }, 500);
    });
    
    // 验证码登录表单提交
    document.getElementById('code-form').addEventListener('submit', function(e) {
      e.preventDefault();
      const alertBox = document.getElementById('alert');
      
      alertBox.classList.remove('show', 'bg-success/10', 'text-success', 'bg-error/10', 'text-error');
      alertBox.innerHTML = '';
      
      setTimeout(() => {
        alertBox.classList.add('show', 'bg-error/10', 'text-error');
        alertBox.innerHTML = '<i class="fas fa-exclamation-circle mr-2"></i> 验证码登录功能暂未开放';
        
        setTimeout(() => {
          alertBox.classList.remove('show');
        }, 3000);
      }, 500);
    });
    
    // 为logo文字和图标添加点击事件
    document.querySelector('.logo-text').addEventListener('click', function() {
      window.location.href = '墨语智学首页.html';
    });
    
    document.querySelector('.logo-icon').addEventListener('click', function() {
      window.location.href = '墨语智学首页.html';
    });
  });
</script>
</body>
</html>